package com.wonders.springboot.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {
    //@PreAuthorize("hasRole('ROLE_普通用户')")
    @PreAuthorize("hasAnyAuthority('menu:user')")
    @GetMapping("/getUser")
    @ResponseBody
    public String getUser(){
        return "访问getUser成功";
    }

    //@PreAuthorize("hasRole('ROLE_管理员')")
    @PreAuthorize("hasAnyAuthority('menu:system')")
    @GetMapping("/getAdmin")
    @ResponseBody
    public String getAdmin(){
        return "访问getAdmin成功";
    }

    @GetMapping(value = "/hello",produces = "text/html; charset=UTF-8")
    @ResponseBody
    public String hello() {
        return "啦啦啦";
    }

}
